#include"TextQuery.h"
#include"QueryResult.h"
#include"Query.h"
#include "WordQuery.h"
#include "Query_base.h"

Query::Query(shared_ptr<Query_base> query) : q(query) {}

Query::Query(const string &s): q(new WordQuery(s)){
    // if(DEBUG) std::cout << "Query::Query(const std::string& s) where s=" + s + "\n";
}   
QueryResult Query::eval(const TextQuery &t) const{ return q->eval(t); }

string Query::rep() const {return q->rep();}

inline std::ostream&
operator<< (std::ostream& os, const Query& query)
{
	// make a virtual call through its Query_base pointer to rep();
	return os << query.rep();
}
